<script setup lang="ts">
import { onMounted,ref } from "vue";
import {getArticleList} from "@/api/article.js"
import ArchiveContent from "./components/ArchiveContent.vue";
let articles = ref([]);
onMounted(()=>{
  getArticles();
})

const getArticles = async(tagId=null)=>{
  const requestObj = {page:1,size:30};
  if(tagId) {
    requestObj.tagId = tagId;
  }
  const res = await getArticleList(requestObj);
  let arr = res.data || [];
  arr.sort((a,b)=>{
    return parseInt(b.createTime)-parseInt(a.createTime);
  })
  console.log(res.data,"?????")
  articles.value = arr;
  console.log(articles,"list")
}

const handleChangeTag = (enumCode)=>{
    getArticles(enumCode)
}

</script>

<template>
  <ArchiveContent type="tag-type" :list="articles" @IdChange="handleChangeTag"/>
</template>

<style scoped lang="scss"></style>
